@using System.Reflection;
@model System.Collections.IList
@{
    if (Model == null)
    {
        return;
    }
    if (Model.Count == 0 || (Model[0] as Easy.Models.EditorEntity)?.ActionType != ActionType.UnAttach)
    {
        var unAttach = Activator.CreateInstance(ViewData.ModelMetadata.ModelType.GetTypeInfo().GetGenericArguments()[0]) as Easy.Models.EditorEntity;
        if (unAttach == null)
        {
            throw new Exception($"{ViewData.ModelMetadata.ModelType.GetTypeInfo().GetGenericArguments()[0].FullName} 必须继承于 Easy.Models.EditorEntity");
        }
        unAttach.ActionType = ActionType.UnAttach;
        Model.Insert(0, unAttach);
    }

}
<div class="input-group-collection container-fluid">
    <div class="Template hide">
        @Html.EditorFor(m => m[0], "ListEditorItem")
    </div>
    <div class="items">
        @{
            Model.RemoveAt(0);
            for (int i = 0; i < Model.Count; i++)
            {
                @Html.EditorFor(m => m[i], "ListEditorItem")
            }
        }
    </div>
    <input type="button" value="@L("添加")" class="btn btn-primary btn-xs add" data-value="@ActionType.Create" />

</div>